
Page({

  data: {
    wxcode: [],
    alicode:[]
  },
  ChooseImage() {
    wx.chooseImage({
      count: 1, 
      sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
      sourceType: ['album'], //从相册选择
      success: (res) => {
        if (this.data.wxcode.length != 0) {
          this.setData({
            wxcode: this.data.wxcode.concat(res.tempFilePaths)
          })
        } else {
          this.setData({
            wxcode: res.tempFilePaths
          })
        }
      }
    });
  },
  ViewImage(e) {
    wx.previewImage({
      urls: this.data.wxcode,
      current: e.currentTarget.dataset.url
    });
  },
  DelImg(e) {
    wx.showModal({
      title: '删除收款码',
      content: '确定要删除微信收款码吗？',
      cancelText: '取消',
      confirmText: '确定',
      success: res => {
        if (res.confirm) {
          this.data.wxcode.splice(e.currentTarget.dataset.index, 1);
          this.setData({
            wxcode: this.data.wxcode
          })
        }
      }
    })
  },
  AliChooseImage() {
    wx.chooseImage({
      count: 1,
      sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
      sourceType: ['album'], //从相册选择
      success: (res) => {
        if (this.data.alicode.length != 0) {
          this.setData({
            alicode: this.data.alicode.concat(res.tempFilePaths)
          })
        } else {
          this.setData({
            alicode: res.tempFilePaths
          })
        }
      }
    });
  },
  AliViewImage(e) {
    wx.previewImage({
      urls: this.data.alicode,
      current: e.currentTarget.dataset.url
    });
  },
  AliDelImg(e) {
    wx.showModal({
      title: '删除收款码',
      content: '确定要删除支付宝收款码吗？',
      cancelText: '取消',
      confirmText: '确定',
      success: res => {
        if (res.confirm) {
          this.data.alicode.splice(e.currentTarget.dataset.index, 1);
          this.setData({
            alicode: this.data.alicode
          })
        }
      }
    })
  },
  formSubmit: function (e) {}

})